<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <table>
      <tr>
        <td>选举人</td>
        <td>票数</td>
        <td>操作</td>
      </tr>
      <tr>
        <td>jack</td>
        <td>0</td>
        <td><button id="btn1">投票</button></td>
      </tr>
      <tr>
        <td>alex</td>
        <td>0</td>
        <td><button id="btn2">投票</button></td>
      </tr>
    </table>
    <script>
      let btn1 = document.getElementById("btn1");
      let btn2 = document.getElementById("btn2");
      let tr1 = btn1.parentNode.parentNode;
      let tr2 = btn2.parentNode.parentNode;
      let timer = null;
      btn1.addEventListener("click", function () {
        tr1.children[1].innerHTML++;
      });
      btn2.addEventListener("click", function () {
        if (timer) {
          clearTimeout(timer);
        }
        timer = setTimeout(function () {
          tr2.children[1].innerHTML++;
        }, 1000);
      });
    </script>
  </body>
</html>
